<script setup lang="ts">
import { reactive, provide } from 'vue'
import { myStore } from '@/store/my';
import EducationalExperiencePopup from './EducationalExperiencePopup.vue';
import { projectDelete } from '@/api/my';
import { Toast } from 'vant';

const props: any = defineProps({
    page:{
        type:String
    }
})

const store = myStore()

const state = reactive({
    show: false,
})

const closeChange = () => {
    state.show = false
    store.getResumeDetail()
}

// 删除
const submitDelete = async (id: any) => {
    const res = await projectDelete({
        id: id
    })
    if (res) {
        Toast('删除成功')
        store.getResumeDetail()
    } else {
        Toast('删除失败')
    }
}

// 修改工作经历
const editWork = () => {
    state.show = true
}

provide('popup', {
    closeChange
})
</script>

<template>
    <div class="resume-label">
        <h3>教育经历<van-icon @click="editWork" name="add-o" v-if="props.page!=='preview'"/></h3>
        <div v-if="store.resumeInfo.school_name">
            <h4>{{ store.resumeInfo.school_name }}<van-icon v-if="props.page!=='preview'" @click="editWork" name="arrow" /></h4>
            <p>{{ store.resumeInfo.teach_start_time }} - {{ store.resumeInfo.teach_end_time }}</p>
            <h5>{{ store.resumeInfo.major }} | {{ store.resumeInfo.highest_education }}</h5>
        </div>
        <label v-else>请您填写教育经历</label>
        <!--弹窗-->
        <van-popup v-model:show="state.show" position="top" duration="0" :style="{ width: '100%', height: '100%' }">
            <EducationalExperiencePopup />
        </van-popup>
    </div>

</template>

<style scoped>
  .position-list{
    margin: 1.52rem 0.67rem 0;
  }
  .work-time-list{
    display: flex;
    align-items: center
  }
  .work-time-list span{
    width: 0.83rem;
    height: 0.05rem;
    margin-right: 2.4rem;
    background: #333333;
  }
  .work-time-list .van-cell{
    width: 6rem;
  }
  .resume-label h5{
    margin-bottom: 0;
  }
</style>